package com.nari.ies.ne.nw.server.service.fileScore.impl;

import com.nari.ies.ne.nw.server.entity.*;
import com.nari.ies.ne.nw.server.mapper.PlantDataMapper;
import com.nari.ies.ne.nw.server.service.fileScore.*;
import com.nari.ies.ne.nw.server.service.plantDataScore.IPvPlantDataScoreService;
import com.nari.ies.ne.nw.server.service.plantDataScore.IWindPlantDataScoreService;
import com.nari.ies.ne.nw.server.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class PlantScoreServiceImpl implements IPlantScoreService {

    @Autowired
    private PlantDataMapper plantDataMapper;
    @Autowired
    private IFDJZFileScoreService FDJZFileScoreService;
    @Autowired
    private ISYZXXFileScoreService SYZXXFileScoreService;
    @Autowired
    private IQXHJFileScoreService QXHJFileScoreService;
    @Autowired
    private IDQYCFileScoreService DQYCFileScoreService;
    @Autowired
    private ICDQYCFileScoreService CDQYCFileScoreService;
    @Autowired
    private ITJXXFileScoreService TJXXFileScoreService;
    @Autowired
    private INBQHLXFileScoreService NBQHLXFileScoreService;
    @Autowired
    private IXBFZFileScoreService XBFZFileScoreService;
    @Autowired
    private IWindPlantDataScoreService windPlantDataScoreService;
    @Autowired
    private IPvPlantDataScoreService pvPlantDataScoreService;


    //读取昨天文件并算分，插入对应场站表中
    @Override
    public void getPlantScoreByYesterday(Date endTime) {
        // 查全网所有场站id
        List<Map<String, Object>> plantData = plantDataMapper.selectAllplantData();
        if (plantData != null) {
          //遍历该省下市级信息id,name,code
           for (Map<String, Object> plantMap : plantData) {
           // 获取场站Id
           String plantId = plantMap.get("ID").toString();
           // 获取区域Id
           String areaId = plantMap.get("AREAID").toString();
           // 获取场站名称
           String plantName = plantMap.get("NAME").toString();
           // 获取场站英文标识符
           String plantNameENG = null;

           if(plantMap.get("CODE")==null){
               plantNameENG="null";
           }else {
               plantNameENG=plantMap.get("CODE").toString();
           }

           String plantType = plantMap.get("PLANT_TYPE").toString();
           int staticType = 1;
           if (plantType.equals("wind")) {
               // 风电场站
               WindFileScoreEntity windFileScoreEntity = new WindFileScoreEntity();
               windFileScoreEntity.setPlantId(plantId);
               windFileScoreEntity.setPlantName(plantName);
               windFileScoreEntity.setPlantNameENG(plantNameENG);
               windFileScoreEntity.setDateTime(endTime);
               windFileScoreEntity.setAreaId(areaId);
               windFileScoreEntity.setStaticType(staticType);

               windFileScoreEntity = FDJZFileScoreService.FDJZFileScore(windFileScoreEntity);
               windFileScoreEntity = SYZXXFileScoreService.FDSYZXXFileScore(windFileScoreEntity);
               windFileScoreEntity = QXHJFileScoreService.FDQXHJFileScore(windFileScoreEntity);
               windFileScoreEntity = DQYCFileScoreService.FDDQYCFileScore(windFileScoreEntity);
               windFileScoreEntity = CDQYCFileScoreService.FDCDQYCFileScore(windFileScoreEntity);
               windFileScoreEntity = TJXXFileScoreService.FDTJXXFileScore(windFileScoreEntity);
               //插入风电表中
               plantDataMapper.insertWindFileScoreEntity(windFileScoreEntity);
           } else if (plantType.equals("pv")) {
               // 光伏场站
               PvFileScoreEntity pvFileScoreEntity = new PvFileScoreEntity();
               pvFileScoreEntity.setPlantId(plantId);
               pvFileScoreEntity.setPlantName(plantName);
               pvFileScoreEntity.setPlantNameENG(plantNameENG);
               pvFileScoreEntity.setDateTime(endTime);
               pvFileScoreEntity.setAreaId(areaId);
               pvFileScoreEntity.setStaticType(1);

               pvFileScoreEntity = NBQHLXFileScoreService.NBQHLXFileScore(pvFileScoreEntity);
               pvFileScoreEntity = SYZXXFileScoreService.GFSYZXXFileScore(pvFileScoreEntity);
               pvFileScoreEntity = QXHJFileScoreService.GFQXHJFileScore(pvFileScoreEntity);
               pvFileScoreEntity = DQYCFileScoreService.GFDQYCFileScore(pvFileScoreEntity);
               pvFileScoreEntity = CDQYCFileScoreService.GFCDQYCFileScore(pvFileScoreEntity);
               pvFileScoreEntity = TJXXFileScoreService.GFTJXXFileScore(pvFileScoreEntity);
               pvFileScoreEntity = XBFZFileScoreService.XBFZFileScore(pvFileScoreEntity);
               //插入光伏表中
               plantDataMapper.insertPvFileScoreEntity(pvFileScoreEntity);
               }
           }
        }
    }

    //根据场站信息并插入对应市级信息
    @Override
    public void getAreaAVGScore(Date startTime,Date endTime,int staticType) {
        // 查阳江所有市区id
        List<Map<String, Object>> areaData = plantDataMapper.selectAllAreaData();
        for (Map<String, Object> areaMap : areaData) {
            AreaFileScoreEntity areaFileScoreEntity = new AreaFileScoreEntity();
            // 获取市级Id
            String areaId = areaMap.get("AREAID").toString();
            // 获取市级名称
            String areaName = areaMap.get("AREANAME").toString();
            // 获取市级英文标识符
            String areaCode = "null";

            areaFileScoreEntity.setAreaId(areaId);
            areaFileScoreEntity.setAreaName(areaName);
            areaFileScoreEntity.setAreaNameENG(areaCode);
            areaFileScoreEntity.setDateTime(endTime);
            areaFileScoreEntity.setStaticType(staticType);
            // 查询该市区下有多少风电场站
            int windPlantNum=plantDataMapper.selectWindPlantNumByAreaId(areaId);
            // 查询该市区下所有风电场站的平均分
            List<Map<String, Object>> avgWindPlantData = plantDataMapper.selectAvgAreaWindPlantData(areaId,startTime,endTime,staticType);
            if(windPlantNum>0 && avgWindPlantData!=null){
                // 插入风电机组
                areaFileScoreEntity.setFDJZWindNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("FDJZ_NUM"))).intValue());
                areaFileScoreEntity.setFDJZWindRate(Float.parseFloat(avgWindPlantData.get(0).get("FDJZ_RATE").toString()));
                areaFileScoreEntity.setFDJZWindScore(Float.parseFloat(avgWindPlantData.get(0).get("FDJZ_SCORE").toString()));
                areaFileScoreEntity.setFDJZWindFullScore(Float.parseFloat(avgWindPlantData.get(0).get("FDJZ_FULL_SCORE").toString()));
                areaFileScoreEntity.setFDJZWindQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("FDJZ_QUAL_RATE").toString()));
                if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("FDJZ_NUM"))).intValue()>0){
                    areaFileScoreEntity.setFDJZWindSendRate(100);
                }else {
                    areaFileScoreEntity.setFDJZWindSendRate(0);
                }
                // 插入升压站信息
                areaFileScoreEntity.setSYZXXWindNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("SYZXX_NUM"))).intValue());
                areaFileScoreEntity.setSYZXXWindRate(Float.parseFloat(avgWindPlantData.get(0).get("SYZXX_RATE").toString()));
                areaFileScoreEntity.setSYZXXWindScore(Float.parseFloat(avgWindPlantData.get(0).get("SYZXX_SCORE").toString()));
                areaFileScoreEntity.setSYZXXWindFullScore(Float.parseFloat(avgWindPlantData.get(0).get("SYZXX_FULL_SCORE").toString()));
                areaFileScoreEntity.setSYZXXWindQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("SYZXX_QUAL_RATE").toString()));
                if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("SYZXX_NUM"))).intValue()>0){
                    areaFileScoreEntity.setSYZXXWindSendRate(100);
                }else {
                    areaFileScoreEntity.setSYZXXWindSendRate(0);
                }
                // 插入总体信息-气象环境
                areaFileScoreEntity.setZTXX_QXHJWindNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("ZTXX_QXHJ_NUM"))).intValue());
                areaFileScoreEntity.setZTXX_QXHJWindRate(Float.parseFloat(avgWindPlantData.get(0).get("ZTXX_QXHJ_RATE").toString()));
                areaFileScoreEntity.setZTXX_QXHJWindScore(Float.parseFloat(avgWindPlantData.get(0).get("ZTXX_QXHJ_SCORE").toString()));
                areaFileScoreEntity.setZTXX_QXHJWindFullScore(Float.parseFloat(avgWindPlantData.get(0).get("ZTXX_QXHJ_FULL_SCORE").toString()));
                areaFileScoreEntity.setZTXX_QXHJWindQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("ZTXX_QXHJ_QUAL_RATE").toString()));
                if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("ZTXX_QXHJ_NUM"))).intValue()>0){
                    areaFileScoreEntity.setZTXX_QXHJWindSendRate(100);
                }else {
                    areaFileScoreEntity.setZTXX_QXHJWindSendRate(0);
                }
                // 插入短期预测
                areaFileScoreEntity.setDQYCWindNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("DQYC_NUM"))).intValue());
                areaFileScoreEntity.setDQYCWindRate(Float.parseFloat(avgWindPlantData.get(0).get("DQYC_RATE").toString()));
                areaFileScoreEntity.setDQYCWindScore(Float.parseFloat(avgWindPlantData.get(0).get("DQYC_SCORE").toString()));
                areaFileScoreEntity.setDQYCWindFullScore(Float.parseFloat(avgWindPlantData.get(0).get("DQYC_FULL_SCORE").toString()));
                areaFileScoreEntity.setDQYCWindQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("DQYC_QUAL_RATE").toString()));
                if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("DQYC_NUM"))).intValue()>0){
                    areaFileScoreEntity.setDQYCWindSendRate(100);
                }else {
                    areaFileScoreEntity.setDQYCWindSendRate(0);
                }
                // 插入超短期预测
                areaFileScoreEntity.setCDQYCWindNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("CDQYC_NUM"))).intValue());
                areaFileScoreEntity.setCDQYCWindRate(Float.parseFloat(avgWindPlantData.get(0).get("CDQYC_RATE").toString()));
                areaFileScoreEntity.setCDQYCWindScore(Float.parseFloat(avgWindPlantData.get(0).get("CDQYC_SCORE").toString()));
                areaFileScoreEntity.setCDQYCWindFullScore(Float.parseFloat(avgWindPlantData.get(0).get("CDQYC_FULL_SCORE").toString()));
                areaFileScoreEntity.setCDQYCWindQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("CDQYC_QUAL_RATE").toString()));
                if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("CDQYC_NUM"))).intValue()>0){
                    areaFileScoreEntity.setCDQYCWindSendRate(100);
                }else {
                    areaFileScoreEntity.setCDQYCWindSendRate(0);
                }
                // 插入统计信息
                areaFileScoreEntity.setTJXXWindNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("TJXX_NUM"))).intValue());
                areaFileScoreEntity.setTJXXWindRate(Float.parseFloat(avgWindPlantData.get(0).get("TJXX_RATE").toString()));
                areaFileScoreEntity.setTJXXWindScore(Float.parseFloat(avgWindPlantData.get(0).get("TJXX_SCORE").toString()));
                areaFileScoreEntity.setTJXXWindFullScore(Float.parseFloat(avgWindPlantData.get(0).get("TJXX_FULL_SCORE").toString()));
                areaFileScoreEntity.setTJXXWindQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("TJXX_QUAL_RATE").toString()));
                if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("TJXX_NUM"))).intValue()>0){
                    areaFileScoreEntity.setTJXXWindSendRate(100);
                }else {
                    areaFileScoreEntity.setTJXXWindSendRate(0);
                }
            }else {
                areaFileScoreEntity.setFDJZWindNum(0);
                areaFileScoreEntity.setFDJZWindRate(0);
                areaFileScoreEntity.setFDJZWindScore(0);
                areaFileScoreEntity.setFDJZWindFullScore(0);
                areaFileScoreEntity.setFDJZWindQualifiedRate(0);
                areaFileScoreEntity.setFDJZWindSendRate(0);
                // 插入升压站信息
                areaFileScoreEntity.setSYZXXWindNum(0);
                areaFileScoreEntity.setSYZXXWindRate(0);
                areaFileScoreEntity.setSYZXXWindScore(0);
                areaFileScoreEntity.setSYZXXWindFullScore(0);
                areaFileScoreEntity.setSYZXXWindQualifiedRate(0);
                areaFileScoreEntity.setSYZXXWindSendRate(0);
                // 插入总体信息-气象环境
                areaFileScoreEntity.setZTXX_QXHJWindNum(0);
                areaFileScoreEntity.setZTXX_QXHJWindRate(0);
                areaFileScoreEntity.setZTXX_QXHJWindScore(0);
                areaFileScoreEntity.setZTXX_QXHJWindFullScore(0);
                areaFileScoreEntity.setZTXX_QXHJWindQualifiedRate(0);
                areaFileScoreEntity.setZTXX_QXHJWindSendRate(0);
                // 插入短期预测
                areaFileScoreEntity.setDQYCWindNum(0);
                areaFileScoreEntity.setDQYCWindRate(0);
                areaFileScoreEntity.setDQYCWindScore(0);
                areaFileScoreEntity.setDQYCWindFullScore(0);
                areaFileScoreEntity.setDQYCWindQualifiedRate(0);
                areaFileScoreEntity.setDQYCWindSendRate(0);
                // 插入超短期预测
                areaFileScoreEntity.setCDQYCWindNum(0);
                areaFileScoreEntity.setCDQYCWindRate(0);
                areaFileScoreEntity.setCDQYCWindScore(0);
                areaFileScoreEntity.setCDQYCWindFullScore(0);
                areaFileScoreEntity.setCDQYCWindQualifiedRate(0);
                areaFileScoreEntity.setCDQYCWindSendRate(0);
                // 插入统计信息
                areaFileScoreEntity.setTJXXWindNum(0);
                areaFileScoreEntity.setTJXXWindRate(0);
                areaFileScoreEntity.setTJXXWindScore(0);
                areaFileScoreEntity.setTJXXWindFullScore(0);
                areaFileScoreEntity.setTJXXWindQualifiedRate(0);
                areaFileScoreEntity.setTJXXWindSendRate(0);
            }
            // 查询该市区下有多少风电场站
            int pvPlantNum=plantDataMapper.selectPvPlantNumByAreaId(areaId);
            // 查询该市区下所有光伏场站的数据
            List<Map<String, Object>> avgPvPlantData = plantDataMapper.selectAvgAreaPvPlantData(areaId,startTime,endTime,staticType);
            if(pvPlantNum>0&&avgPvPlantData!=null){
                // 插入箱变方阵
                areaFileScoreEntity.setXB_FZPvNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("XB_FZ_NUM"))).intValue());
                areaFileScoreEntity.setXB_FZPvRate(Float.parseFloat(avgPvPlantData.get(0).get("XB_FZ_RATE").toString()));
                areaFileScoreEntity.setXB_FZPvScore(Float.parseFloat(avgPvPlantData.get(0).get("XB_FZ_SCORE").toString()));
                areaFileScoreEntity.setXB_FZPvFullScore(Float.parseFloat(avgPvPlantData.get(0).get("XB_FZ_FULL_SCORE").toString()));
                areaFileScoreEntity.setXB_FZPvQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("XB_FZ_QUAL_RATE").toString()));
                if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("XB_FZ_NUM"))).intValue()>0){
                    areaFileScoreEntity.setXB_FZPvSendRate(100);
                }else {
                    areaFileScoreEntity.setXB_FZPvSendRate(0);
                }
                // 插入升压站信息
                areaFileScoreEntity.setSYZXXPvNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("SYZXX_NUM"))).intValue());
                areaFileScoreEntity.setSYZXXPvRate(Float.parseFloat(avgPvPlantData.get(0).get("SYZXX_RATE").toString()));
                areaFileScoreEntity.setSYZXXPvScore(Float.parseFloat(avgPvPlantData.get(0).get("SYZXX_SCORE").toString()));
                areaFileScoreEntity.setSYZXXPvFullScore(Float.parseFloat(avgPvPlantData.get(0).get("SYZXX_FULL_SCORE").toString()));
                areaFileScoreEntity.setSYZXXPvQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("SYZXX_QUAL_RATE").toString()));
                if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("SYZXX_NUM"))).intValue()>0){
                    areaFileScoreEntity.setSYZXXPvSendRate(100);
                }else {
                    areaFileScoreEntity.setSYZXXPvSendRate(0);
                }
                // 插入总体信息-气象环境
                areaFileScoreEntity.setZTXX_QXHJ_TYGZPvNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_NUM"))).intValue());
                areaFileScoreEntity.setZTXX_QXHJ_TYGZPvRate(Float.parseFloat(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_RATE").toString()));
                areaFileScoreEntity.setZTXX_QXHJ_TYGZPvScore(Float.parseFloat(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_SCORE").toString()));
                areaFileScoreEntity.setZTXX_QXHJ_TYGZPvFullScore(Float.parseFloat(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_FULL_SCORE").toString()));
                areaFileScoreEntity.setZTXX_QXHJ_TYGZPvQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_QUAL_RATE").toString()));
                if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_NUM"))).intValue()>0){
                    areaFileScoreEntity.setZTXX_QXHJ_TYGZPvSendRate(100);
                }else {
                    areaFileScoreEntity.setZTXX_QXHJ_TYGZPvSendRate(0);
                }
                // 插入短期预测
                areaFileScoreEntity.setDQYCPvNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("DQYC_NUM"))).intValue());
                areaFileScoreEntity.setDQYCPvRate(Float.parseFloat(avgPvPlantData.get(0).get("DQYC_RATE").toString()));
                areaFileScoreEntity.setDQYCPvScore(Float.parseFloat(avgPvPlantData.get(0).get("DQYC_SCORE").toString()));
                areaFileScoreEntity.setDQYCPvFullScore(Float.parseFloat(avgPvPlantData.get(0).get("DQYC_FULL_SCORE").toString()));
                areaFileScoreEntity.setDQYCPvQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("DQYC_QUAL_RATE").toString()));
                if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("DQYC_NUM"))).intValue()>0){
                    areaFileScoreEntity.setDQYCPvSendRate(100);
                }else {
                    areaFileScoreEntity.setDQYCPvSendRate(0);
                }
                // 插入超短期预测
                areaFileScoreEntity.setCDQYCPvNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("CDQYC_NUM"))).intValue());
                areaFileScoreEntity.setCDQYCPvRate(Float.parseFloat(avgPvPlantData.get(0).get("CDQYC_RATE").toString()));
                areaFileScoreEntity.setCDQYCPvScore(Float.parseFloat(avgPvPlantData.get(0).get("CDQYC_SCORE").toString()));
                areaFileScoreEntity.setCDQYCPvFullScore(Float.parseFloat(avgPvPlantData.get(0).get("CDQYC_FULL_SCORE").toString()));
                areaFileScoreEntity.setCDQYCPvQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("CDQYC_QUAL_RATE").toString()));
                if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("CDQYC_NUM"))).intValue()>0){
                    areaFileScoreEntity.setCDQYCPvSendRate(100);
                }else {
                    areaFileScoreEntity.setCDQYCPvSendRate(0);
                }
                // 插入统计信息
                areaFileScoreEntity.setTJXXPvNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("TJXX_NUM"))).intValue());
                areaFileScoreEntity.setTJXXPvRate(Float.parseFloat(avgPvPlantData.get(0).get("TJXX_RATE").toString()));
                areaFileScoreEntity.setTJXXPvScore(Float.parseFloat(avgPvPlantData.get(0).get("TJXX_SCORE").toString()));
                areaFileScoreEntity.setTJXXPvFullScore(Float.parseFloat(avgPvPlantData.get(0).get("TJXX_FULL_SCORE").toString()));
                areaFileScoreEntity.setTJXXPvQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("TJXX_QUAL_RATE").toString()));
                if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("TJXX_NUM"))).intValue()>0){
                    areaFileScoreEntity.setTJXXPvSendRate(100);
                }else {
                    areaFileScoreEntity.setTJXXPvSendRate(0);
                }
                // 插入逆变器-汇流箱
                areaFileScoreEntity.setNBQ_HLXPvNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("NBQ_HLX_NUM"))).intValue());
                areaFileScoreEntity.setNBQ_HLXPvRate(Float.parseFloat(avgPvPlantData.get(0).get("NBQ_HLX_RATE").toString()));
                areaFileScoreEntity.setNBQ_HLXPvScore(Float.parseFloat(avgPvPlantData.get(0).get("NBQ_HLX_SCORE").toString()));
                areaFileScoreEntity.setNBQ_HLXPvFullScore(Float.parseFloat(avgPvPlantData.get(0).get("NBQ_HLX_FULL_SCORE").toString()));
                areaFileScoreEntity.setNBQ_HLXPvQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("NBQ_HLX_QUAL_RATE").toString()));
                if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("NBQ_HLX_NUM"))).intValue()>0){
                    areaFileScoreEntity.setNBQ_HLXPvSendRate(100);
                }else {
                    areaFileScoreEntity.setNBQ_HLXPvSendRate(0);
                }
            }else {
                // 插入箱变方阵
                areaFileScoreEntity.setXB_FZPvNum(0);
                areaFileScoreEntity.setXB_FZPvRate(0);
                areaFileScoreEntity.setXB_FZPvScore(0);
                areaFileScoreEntity.setXB_FZPvFullScore(0);
                areaFileScoreEntity.setXB_FZPvQualifiedRate(0);
                areaFileScoreEntity.setXB_FZPvSendRate(0);
                // 插入升压站信息
                areaFileScoreEntity.setSYZXXPvNum(0);
                areaFileScoreEntity.setSYZXXPvRate(0);
                areaFileScoreEntity.setSYZXXPvScore(0);
                areaFileScoreEntity.setSYZXXPvFullScore(0);
                areaFileScoreEntity.setSYZXXPvQualifiedRate(0);
                areaFileScoreEntity.setSYZXXPvSendRate(0);
                // 插入总体信息-气象环境
                areaFileScoreEntity.setZTXX_QXHJ_TYGZPvNum(0);
                areaFileScoreEntity.setZTXX_QXHJ_TYGZPvRate(0);
                areaFileScoreEntity.setZTXX_QXHJ_TYGZPvScore(0);
                areaFileScoreEntity.setZTXX_QXHJ_TYGZPvFullScore(0);
                areaFileScoreEntity.setZTXX_QXHJ_TYGZPvQualifiedRate(0);
                areaFileScoreEntity.setZTXX_QXHJ_TYGZPvSendRate(100);
                // 插入短期预测
                areaFileScoreEntity.setDQYCPvNum(0);
                areaFileScoreEntity.setDQYCPvRate(0);
                areaFileScoreEntity.setDQYCPvScore(0);
                areaFileScoreEntity.setDQYCPvFullScore(0);
                areaFileScoreEntity.setDQYCPvQualifiedRate(0);
                areaFileScoreEntity.setDQYCPvSendRate(0);
                // 插入超短期预测
                areaFileScoreEntity.setCDQYCPvNum(0);
                areaFileScoreEntity.setCDQYCPvRate(0);
                areaFileScoreEntity.setCDQYCPvScore(0);
                areaFileScoreEntity.setCDQYCPvFullScore(0);
                areaFileScoreEntity.setCDQYCPvQualifiedRate(0);
                areaFileScoreEntity.setCDQYCPvSendRate(0);
                // 插入统计信息
                areaFileScoreEntity.setTJXXPvNum(0);
                areaFileScoreEntity.setTJXXPvRate(0);
                areaFileScoreEntity.setTJXXPvScore(0);
                areaFileScoreEntity.setTJXXPvFullScore(0);
                areaFileScoreEntity.setTJXXPvQualifiedRate(0);
                areaFileScoreEntity.setTJXXPvSendRate(0);
                // 插入逆变器-汇流箱
                areaFileScoreEntity.setNBQ_HLXPvNum(0);
                areaFileScoreEntity.setNBQ_HLXPvRate(0);
                areaFileScoreEntity.setNBQ_HLXPvScore(0);
                areaFileScoreEntity.setNBQ_HLXPvFullScore(0);
                areaFileScoreEntity.setNBQ_HLXPvQualifiedRate(0);
                areaFileScoreEntity.setNBQ_HLXPvSendRate(0);
                }
            plantDataMapper.insertAreaFileScoreEntity(areaFileScoreEntity);
        }
     }


    //根据场站信息并插入阳江全市信息
    @Override
    public void getYJAVGScore(Date startTime,Date endTime,int staticType) {
        AreaFileScoreEntity areaFileScoreEntity = new AreaFileScoreEntity();
        Map<String, Object> YJData = plantDataMapper.selectYJData();
        // 获取阳江Id
        String yjId = YJData.get("YJID").toString();
        // 获取阳江名称
        String yjName = YJData.get("YJNAME").toString();
        String yjCode = "null";

        areaFileScoreEntity.setAreaId(yjId);
        areaFileScoreEntity.setAreaName(yjName);
        areaFileScoreEntity.setAreaNameENG(yjCode);
        areaFileScoreEntity.setDateTime(endTime);
        areaFileScoreEntity.setStaticType(staticType);
        // 查询阳江有多少风电场站
        int windPlantNum=plantDataMapper.selectWindPlantNumByYJId();
        // 查询该省区下所有风电场站的平均分
        List<Map<String, Object>> avgWindPlantData = plantDataMapper.selectAvgYJWindData(startTime,endTime);
        if(windPlantNum>0 && avgWindPlantData!=null){
            // 插入风电机组
            areaFileScoreEntity.setFDJZWindNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("FDJZ_NUM"))).intValue());
            areaFileScoreEntity.setFDJZWindRate(Float.parseFloat(avgWindPlantData.get(0).get("FDJZ_RATE").toString()));
            areaFileScoreEntity.setFDJZWindScore(Float.parseFloat(avgWindPlantData.get(0).get("FDJZ_SCORE").toString()));
            areaFileScoreEntity.setFDJZWindFullScore(Float.parseFloat(avgWindPlantData.get(0).get("FDJZ_FULL_SCORE").toString()));
            areaFileScoreEntity.setFDJZWindQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("FDJZ_QUAL_RATE").toString()));
            if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("FDJZ_NUM"))).intValue()>0){
                areaFileScoreEntity.setFDJZWindSendRate(100);
            }else {
                areaFileScoreEntity.setFDJZWindSendRate(0);
            }
            // 插入升压站信息
            areaFileScoreEntity.setSYZXXWindNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("SYZXX_NUM"))).intValue());
            areaFileScoreEntity.setSYZXXWindRate(Float.parseFloat(avgWindPlantData.get(0).get("SYZXX_RATE").toString()));
            areaFileScoreEntity.setSYZXXWindScore(Float.parseFloat(avgWindPlantData.get(0).get("SYZXX_SCORE").toString()));
            areaFileScoreEntity.setSYZXXWindFullScore(Float.parseFloat(avgWindPlantData.get(0).get("SYZXX_FULL_SCORE").toString()));
            areaFileScoreEntity.setSYZXXWindQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("SYZXX_QUAL_RATE").toString()));
            if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("SYZXX_NUM"))).intValue()>0){
                areaFileScoreEntity.setSYZXXWindSendRate(100);
            }else {
                areaFileScoreEntity.setSYZXXWindSendRate(0);
            }
            // 插入总体信息-气象环境
            areaFileScoreEntity.setZTXX_QXHJWindNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("ZTXX_QXHJ_NUM"))).intValue());
            areaFileScoreEntity.setZTXX_QXHJWindRate(Float.parseFloat(avgWindPlantData.get(0).get("ZTXX_QXHJ_RATE").toString()));
            areaFileScoreEntity.setZTXX_QXHJWindScore(Float.parseFloat(avgWindPlantData.get(0).get("ZTXX_QXHJ_SCORE").toString()));
            areaFileScoreEntity.setZTXX_QXHJWindFullScore(Float.parseFloat(avgWindPlantData.get(0).get("ZTXX_QXHJ_FULL_SCORE").toString()));
            areaFileScoreEntity.setZTXX_QXHJWindQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("ZTXX_QXHJ_QUAL_RATE").toString()));
            if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("ZTXX_QXHJ_NUM"))).intValue()>0){
                areaFileScoreEntity.setZTXX_QXHJWindSendRate(100);
            }else {
                areaFileScoreEntity.setZTXX_QXHJWindSendRate(0);
            }
            // 插入短期预测
            areaFileScoreEntity.setDQYCWindNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("DQYC_NUM"))).intValue());
            areaFileScoreEntity.setDQYCWindRate(Float.parseFloat(avgWindPlantData.get(0).get("DQYC_RATE").toString()));
            areaFileScoreEntity.setDQYCWindScore(Float.parseFloat(avgWindPlantData.get(0).get("DQYC_SCORE").toString()));
            areaFileScoreEntity.setDQYCWindFullScore(Float.parseFloat(avgWindPlantData.get(0).get("DQYC_FULL_SCORE").toString()));
            areaFileScoreEntity.setDQYCWindQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("DQYC_QUAL_RATE").toString()));
            if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("DQYC_NUM"))).intValue()>0){
                areaFileScoreEntity.setDQYCWindSendRate(100);
            }else {
                areaFileScoreEntity.setDQYCWindSendRate(0);
            }
            // 插入超短期预测
            areaFileScoreEntity.setCDQYCWindNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("CDQYC_NUM"))).intValue());
            areaFileScoreEntity.setCDQYCWindRate(Float.parseFloat(avgWindPlantData.get(0).get("CDQYC_RATE").toString()));
            areaFileScoreEntity.setCDQYCWindScore(Float.parseFloat(avgWindPlantData.get(0).get("CDQYC_SCORE").toString()));
            areaFileScoreEntity.setCDQYCWindFullScore(Float.parseFloat(avgWindPlantData.get(0).get("CDQYC_FULL_SCORE").toString()));
            areaFileScoreEntity.setCDQYCWindQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("CDQYC_QUAL_RATE").toString()));
            if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("CDQYC_NUM"))).intValue()>0){
                areaFileScoreEntity.setCDQYCWindSendRate(100);
            }else {
                areaFileScoreEntity.setCDQYCWindSendRate(0);
            }
            // 插入统计信息
            areaFileScoreEntity.setTJXXWindNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("TJXX_NUM"))).intValue());
            areaFileScoreEntity.setTJXXWindRate(Float.parseFloat(avgWindPlantData.get(0).get("TJXX_RATE").toString()));
            areaFileScoreEntity.setTJXXWindScore(Float.parseFloat(avgWindPlantData.get(0).get("TJXX_SCORE").toString()));
            areaFileScoreEntity.setTJXXWindFullScore(Float.parseFloat(avgWindPlantData.get(0).get("TJXX_FULL_SCORE").toString()));
            areaFileScoreEntity.setTJXXWindQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("TJXX_QUAL_RATE").toString()));
            if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("TJXX_NUM"))).intValue()>0){
                areaFileScoreEntity.setTJXXWindSendRate(100);
            }else {
                areaFileScoreEntity.setTJXXWindSendRate(0);
            }
        }else {
            areaFileScoreEntity.setFDJZWindNum(0);
            areaFileScoreEntity.setFDJZWindRate(0);
            areaFileScoreEntity.setFDJZWindScore(0);
            areaFileScoreEntity.setFDJZWindFullScore(0);
            areaFileScoreEntity.setFDJZWindQualifiedRate(0);
            areaFileScoreEntity.setFDJZWindSendRate(0);
            // 插入升压站信息
            areaFileScoreEntity.setSYZXXWindNum(0);
            areaFileScoreEntity.setSYZXXWindRate(0);
            areaFileScoreEntity.setSYZXXWindScore(0);
            areaFileScoreEntity.setSYZXXWindFullScore(0);
            areaFileScoreEntity.setSYZXXWindQualifiedRate(0);
            areaFileScoreEntity.setSYZXXWindSendRate(0);
            // 插入总体信息-气象环境
            areaFileScoreEntity.setZTXX_QXHJWindNum(0);
            areaFileScoreEntity.setZTXX_QXHJWindRate(0);
            areaFileScoreEntity.setZTXX_QXHJWindScore(0);
            areaFileScoreEntity.setZTXX_QXHJWindFullScore(0);
            areaFileScoreEntity.setZTXX_QXHJWindQualifiedRate(0);
            areaFileScoreEntity.setZTXX_QXHJWindSendRate(0);
            // 插入短期预测
            areaFileScoreEntity.setDQYCWindNum(0);
            areaFileScoreEntity.setDQYCWindRate(0);
            areaFileScoreEntity.setDQYCWindScore(0);
            areaFileScoreEntity.setDQYCWindFullScore(0);
            areaFileScoreEntity.setDQYCWindQualifiedRate(0);
            areaFileScoreEntity.setDQYCWindSendRate(0);
            // 插入超短期预测
            areaFileScoreEntity.setCDQYCWindNum(0);
            areaFileScoreEntity.setCDQYCWindRate(0);
            areaFileScoreEntity.setCDQYCWindScore(0);
            areaFileScoreEntity.setCDQYCWindFullScore(0);
            areaFileScoreEntity.setCDQYCWindQualifiedRate(0);
            areaFileScoreEntity.setCDQYCWindSendRate(0);
            // 插入统计信息
            areaFileScoreEntity.setTJXXWindNum(0);
            areaFileScoreEntity.setTJXXWindRate(0);
            areaFileScoreEntity.setTJXXWindScore(0);
            areaFileScoreEntity.setTJXXWindFullScore(0);
            areaFileScoreEntity.setTJXXWindQualifiedRate(0);
            areaFileScoreEntity.setTJXXWindSendRate(0);
        }
        // 查询该省区下有多少风电场站
        int pvPlantNum=plantDataMapper.selectPvPlantNumByYJId();
        // 查询该省区下所有光伏场站的数据
        List<Map<String, Object>> avgPvPlantData = plantDataMapper.selectAvgYJPvData(startTime,endTime);
        if(pvPlantNum>0&&avgPvPlantData!=null){
            // 插入箱变方阵
            areaFileScoreEntity.setXB_FZPvNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("XB_FZ_NUM"))).intValue());
            areaFileScoreEntity.setXB_FZPvRate(Float.parseFloat(avgPvPlantData.get(0).get("XB_FZ_RATE").toString()));
            areaFileScoreEntity.setXB_FZPvScore(Float.parseFloat(avgPvPlantData.get(0).get("XB_FZ_SCORE").toString()));
            areaFileScoreEntity.setXB_FZPvFullScore(Float.parseFloat(avgPvPlantData.get(0).get("XB_FZ_FULL_SCORE").toString()));
            areaFileScoreEntity.setXB_FZPvQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("XB_FZ_QUAL_RATE").toString()));
            if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("XB_FZ_NUM"))).intValue()>0){
                areaFileScoreEntity.setXB_FZPvSendRate(100);
            }else {
                areaFileScoreEntity.setXB_FZPvSendRate(0);
            }
            // 插入升压站信息
            areaFileScoreEntity.setSYZXXPvNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("SYZXX_NUM"))).intValue());
            areaFileScoreEntity.setSYZXXPvRate(Float.parseFloat(avgPvPlantData.get(0).get("SYZXX_RATE").toString()));
            areaFileScoreEntity.setSYZXXPvScore(Float.parseFloat(avgPvPlantData.get(0).get("SYZXX_SCORE").toString()));
            areaFileScoreEntity.setSYZXXPvFullScore(Float.parseFloat(avgPvPlantData.get(0).get("SYZXX_FULL_SCORE").toString()));
            areaFileScoreEntity.setSYZXXPvQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("SYZXX_QUAL_RATE").toString()));
            if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("SYZXX_NUM"))).intValue()>0){
                areaFileScoreEntity.setSYZXXPvSendRate(100);
            }else {
                areaFileScoreEntity.setSYZXXPvSendRate(0);
            }
            // 插入总体信息-气象环境
            areaFileScoreEntity.setZTXX_QXHJ_TYGZPvNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_NUM"))).intValue());
            areaFileScoreEntity.setZTXX_QXHJ_TYGZPvRate(Float.parseFloat(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_RATE").toString()));
            areaFileScoreEntity.setZTXX_QXHJ_TYGZPvScore(Float.parseFloat(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_SCORE").toString()));
            areaFileScoreEntity.setZTXX_QXHJ_TYGZPvFullScore(Float.parseFloat(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_FULL_SCORE").toString()));
            areaFileScoreEntity.setZTXX_QXHJ_TYGZPvQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_QUAL_RATE").toString()));
            if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_NUM"))).intValue()>0){
                areaFileScoreEntity.setZTXX_QXHJ_TYGZPvSendRate(100);
            }else {
                areaFileScoreEntity.setZTXX_QXHJ_TYGZPvSendRate(0);
            }
            // 插入短期预测
            areaFileScoreEntity.setDQYCPvNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("DQYC_NUM"))).intValue());
            areaFileScoreEntity.setDQYCPvRate(Float.parseFloat(avgPvPlantData.get(0).get("DQYC_RATE").toString()));
            areaFileScoreEntity.setDQYCPvScore(Float.parseFloat(avgPvPlantData.get(0).get("DQYC_SCORE").toString()));
            areaFileScoreEntity.setDQYCPvFullScore(Float.parseFloat(avgPvPlantData.get(0).get("DQYC_FULL_SCORE").toString()));
            areaFileScoreEntity.setDQYCPvQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("DQYC_QUAL_RATE").toString()));
            if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("DQYC_NUM"))).intValue()>0){
                areaFileScoreEntity.setDQYCPvSendRate(100);
            }else {
                areaFileScoreEntity.setDQYCPvSendRate(0);
            }
            // 插入超短期预测
            areaFileScoreEntity.setCDQYCPvNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("CDQYC_NUM"))).intValue());
            areaFileScoreEntity.setCDQYCPvRate(Float.parseFloat(avgPvPlantData.get(0).get("CDQYC_RATE").toString()));
            areaFileScoreEntity.setCDQYCPvScore(Float.parseFloat(avgPvPlantData.get(0).get("CDQYC_SCORE").toString()));
            areaFileScoreEntity.setCDQYCPvFullScore(Float.parseFloat(avgPvPlantData.get(0).get("CDQYC_FULL_SCORE").toString()));
            areaFileScoreEntity.setCDQYCPvQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("CDQYC_QUAL_RATE").toString()));
            if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("CDQYC_NUM"))).intValue()>0){
                areaFileScoreEntity.setCDQYCPvSendRate(100);
            }else {
                areaFileScoreEntity.setCDQYCPvSendRate(0);
            }
            // 插入统计信息
            areaFileScoreEntity.setTJXXPvNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("TJXX_NUM"))).intValue());
            areaFileScoreEntity.setTJXXPvRate(Float.parseFloat(avgPvPlantData.get(0).get("TJXX_RATE").toString()));
            areaFileScoreEntity.setTJXXPvScore(Float.parseFloat(avgPvPlantData.get(0).get("TJXX_SCORE").toString()));
            areaFileScoreEntity.setTJXXPvFullScore(Float.parseFloat(avgPvPlantData.get(0).get("TJXX_FULL_SCORE").toString()));
            areaFileScoreEntity.setTJXXPvQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("TJXX_QUAL_RATE").toString()));
            if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("TJXX_NUM"))).intValue()>0){
                areaFileScoreEntity.setTJXXPvSendRate(100);
            }else {
                areaFileScoreEntity.setTJXXPvSendRate(0);
            }
            // 插入逆变器-汇流箱
            areaFileScoreEntity.setNBQ_HLXPvNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("NBQ_HLX_NUM"))).intValue());
            areaFileScoreEntity.setNBQ_HLXPvRate(Float.parseFloat(avgPvPlantData.get(0).get("NBQ_HLX_RATE").toString()));
            areaFileScoreEntity.setNBQ_HLXPvScore(Float.parseFloat(avgPvPlantData.get(0).get("NBQ_HLX_SCORE").toString()));
            areaFileScoreEntity.setNBQ_HLXPvFullScore(Float.parseFloat(avgPvPlantData.get(0).get("NBQ_HLX_FULL_SCORE").toString()));
            areaFileScoreEntity.setNBQ_HLXPvQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("NBQ_HLX_QUAL_RATE").toString()));
            if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("NBQ_HLX_NUM"))).intValue()>0){
                areaFileScoreEntity.setNBQ_HLXPvSendRate(100);
            }else {
                areaFileScoreEntity.setNBQ_HLXPvSendRate(0);
            }
        }else {
            // 插入箱变方阵
            areaFileScoreEntity.setXB_FZPvNum(0);
            areaFileScoreEntity.setXB_FZPvRate(0);
            areaFileScoreEntity.setXB_FZPvScore(0);
            areaFileScoreEntity.setXB_FZPvFullScore(0);
            areaFileScoreEntity.setXB_FZPvQualifiedRate(0);
            areaFileScoreEntity.setXB_FZPvSendRate(0);
            // 插入升压站信息
            areaFileScoreEntity.setSYZXXPvNum(0);
            areaFileScoreEntity.setSYZXXPvRate(0);
            areaFileScoreEntity.setSYZXXPvScore(0);
            areaFileScoreEntity.setSYZXXPvFullScore(0);
            areaFileScoreEntity.setSYZXXPvQualifiedRate(0);
            areaFileScoreEntity.setSYZXXPvSendRate(0);
            // 插入总体信息-气象环境
            areaFileScoreEntity.setZTXX_QXHJ_TYGZPvNum(0);
            areaFileScoreEntity.setZTXX_QXHJ_TYGZPvRate(0);
            areaFileScoreEntity.setZTXX_QXHJ_TYGZPvScore(0);
            areaFileScoreEntity.setZTXX_QXHJ_TYGZPvFullScore(0);
            areaFileScoreEntity.setZTXX_QXHJ_TYGZPvQualifiedRate(0);
            areaFileScoreEntity.setZTXX_QXHJ_TYGZPvSendRate(100);
            // 插入短期预测
            areaFileScoreEntity.setDQYCPvNum(0);
            areaFileScoreEntity.setDQYCPvRate(0);
            areaFileScoreEntity.setDQYCPvScore(0);
            areaFileScoreEntity.setDQYCPvFullScore(0);
            areaFileScoreEntity.setDQYCPvQualifiedRate(0);
            areaFileScoreEntity.setDQYCPvSendRate(0);
            // 插入超短期预测
            areaFileScoreEntity.setCDQYCPvNum(0);
            areaFileScoreEntity.setCDQYCPvRate(0);
            areaFileScoreEntity.setCDQYCPvScore(0);
            areaFileScoreEntity.setCDQYCPvFullScore(0);
            areaFileScoreEntity.setCDQYCPvQualifiedRate(0);
            areaFileScoreEntity.setCDQYCPvSendRate(0);
            // 插入统计信息
            areaFileScoreEntity.setTJXXPvNum(0);
            areaFileScoreEntity.setTJXXPvRate(0);
            areaFileScoreEntity.setTJXXPvScore(0);
            areaFileScoreEntity.setTJXXPvFullScore(0);
            areaFileScoreEntity.setTJXXPvQualifiedRate(0);
            areaFileScoreEntity.setTJXXPvSendRate(0);
            // 插入逆变器-汇流箱
            areaFileScoreEntity.setNBQ_HLXPvNum(0);
            areaFileScoreEntity.setNBQ_HLXPvRate(0);
            areaFileScoreEntity.setNBQ_HLXPvScore(0);
            areaFileScoreEntity.setNBQ_HLXPvFullScore(0);
            areaFileScoreEntity.setNBQ_HLXPvQualifiedRate(0);
            areaFileScoreEntity.setNBQ_HLXPvSendRate(0);
        }
        plantDataMapper.insertAreaFileScoreEntity(areaFileScoreEntity);

    }

    //根据场站信息并插入对应场站信息
    @Override
    public void getPlantAVGScore(Date startTime, Date endTime, int staticType) {
        // 查阳江所有场站id
        List<Map<String, Object>> plantData = plantDataMapper.selectAllplantData();
        if (plantData != null) {
            //遍历阳江下市级信息id,name,code
            for (Map<String, Object> plantMap : plantData) {
                // 获取场站Id
                String plantId = plantMap.get("ID").toString();
                // 获取区域Id
                String areaId = plantMap.get("AREAID").toString();
                // 获取场站名称
                String plantName = plantMap.get("NAME").toString();
                // 获取场站英文标识符
                String plantNameENG ="null";
                String plantType = plantMap.get("PLANT_TYPE").toString();

                if (plantType.equals("wind")) {
                    // 风电场站
                    WindFileScoreEntity windFileScoreEntity = new WindFileScoreEntity();
                    windFileScoreEntity.setPlantId(plantId);
                    windFileScoreEntity.setPlantName(plantName);
                    windFileScoreEntity.setPlantNameENG(plantNameENG);
                    windFileScoreEntity.setDateTime(endTime);
                    windFileScoreEntity.setAreaId(areaId);
                    windFileScoreEntity.setStaticType(staticType);
                    // 查询该风电场站的平均分
                    List<Map<String, Object>> avgWindPlantData = plantDataMapper.selectAvgWindPlantData(plantId,startTime,endTime);
                    // 插入风电机组
                    windFileScoreEntity.setFDJZNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("FDJZ_NUM"))).intValue());
                    windFileScoreEntity.setFDJZRate(Float.parseFloat(avgWindPlantData.get(0).get("FDJZ_RATE").toString()));
                    windFileScoreEntity.setFDJZScore(Float.parseFloat(avgWindPlantData.get(0).get("FDJZ_SCORE").toString()));
                    windFileScoreEntity.setFDJZFullScore(Float.parseFloat(avgWindPlantData.get(0).get("FDJZ_FULL_SCORE").toString()));
                    windFileScoreEntity.setFDJZQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("FDJZ_QUAL_RATE").toString()));
                    if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("FDJZ_NUM"))).intValue()>0){
                        windFileScoreEntity.setFDJZSendRate(100);
                    }else {
                        windFileScoreEntity.setFDJZSendRate(0);
                    }
                    // 插入升压站信息
                    windFileScoreEntity.setSYZXXNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("SYZXX_NUM"))).intValue());
                    windFileScoreEntity.setSYZXXRate(Float.parseFloat(avgWindPlantData.get(0).get("SYZXX_RATE").toString()));
                    windFileScoreEntity.setSYZXXScore(Float.parseFloat(avgWindPlantData.get(0).get("SYZXX_SCORE").toString()));
                    windFileScoreEntity.setSYZXXFullScore(Float.parseFloat(avgWindPlantData.get(0).get("SYZXX_FULL_SCORE").toString()));
                    windFileScoreEntity.setSYZXXQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("SYZXX_QUAL_RATE").toString()));
                    if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("SYZXX_NUM"))).intValue()>0){
                        windFileScoreEntity.setSYZXXSendRate(100);
                    }else {
                        windFileScoreEntity.setSYZXXSendRate(0);
                    }
                    // 插入总体信息-气象环境
                    windFileScoreEntity.setZTXX_QXHJNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("ZTXX_QXHJ_NUM"))).intValue());
                    windFileScoreEntity.setZTXX_QXHJRate(Float.parseFloat(avgWindPlantData.get(0).get("ZTXX_QXHJ_RATE").toString()));
                    windFileScoreEntity.setZTXX_QXHJScore(Float.parseFloat(avgWindPlantData.get(0).get("ZTXX_QXHJ_SCORE").toString()));
                    windFileScoreEntity.setZTXX_QXHJFullScore(Float.parseFloat(avgWindPlantData.get(0).get("ZTXX_QXHJ_FULL_SCORE").toString()));
                    windFileScoreEntity.setZTXX_QXHJQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("ZTXX_QXHJ_QUAL_RATE").toString()));
                    if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("ZTXX_QXHJ_NUM"))).intValue()>0){
                        windFileScoreEntity.setZTXX_QXHJSendRate(100);
                    }else {
                        windFileScoreEntity.setZTXX_QXHJSendRate(0);
                    }
                    // 插入短期预测
                    windFileScoreEntity.setDQYCNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("DQYC_NUM"))).intValue());
                    windFileScoreEntity.setDQYCRate(Float.parseFloat(avgWindPlantData.get(0).get("DQYC_RATE").toString()));
                    windFileScoreEntity.setDQYCScore(Float.parseFloat(avgWindPlantData.get(0).get("DQYC_SCORE").toString()));
                    windFileScoreEntity.setDQYCFullScore(Float.parseFloat(avgWindPlantData.get(0).get("DQYC_FULL_SCORE").toString()));
                    windFileScoreEntity.setDQYCQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("DQYC_QUAL_RATE").toString()));
                    if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("DQYC_NUM"))).intValue()>0){
                        windFileScoreEntity.setDQYCSendRate(100);
                    }else {
                        windFileScoreEntity.setDQYCSendRate(0);
                    }
                    // 插入超短期预测
                    windFileScoreEntity.setCDQYCNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("CDQYC_NUM"))).intValue());
                    windFileScoreEntity.setCDQYCRate(Float.parseFloat(avgWindPlantData.get(0).get("CDQYC_RATE").toString()));
                    windFileScoreEntity.setCDQYCScore(Float.parseFloat(avgWindPlantData.get(0).get("CDQYC_SCORE").toString()));
                    windFileScoreEntity.setCDQYCFullScore(Float.parseFloat(avgWindPlantData.get(0).get("CDQYC_FULL_SCORE").toString()));
                    windFileScoreEntity.setCDQYCQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("CDQYC_QUAL_RATE").toString()));
                    if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("CDQYC_NUM"))).intValue()>0){
                        windFileScoreEntity.setCDQYCSendRate(100);
                    }else {
                        windFileScoreEntity.setCDQYCSendRate(0);
                    }
                    // 插入统计信息
                    windFileScoreEntity.setTJXXNum(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("TJXX_NUM"))).intValue());
                    windFileScoreEntity.setTJXXRate(Float.parseFloat(avgWindPlantData.get(0).get("TJXX_RATE").toString()));
                    windFileScoreEntity.setTJXXScore(Float.parseFloat(avgWindPlantData.get(0).get("TJXX_SCORE").toString()));
                    windFileScoreEntity.setTJXXFullScore(Float.parseFloat(avgWindPlantData.get(0).get("TJXX_FULL_SCORE").toString()));
                    windFileScoreEntity.setTJXXQualifiedRate(Float.parseFloat(avgWindPlantData.get(0).get("TJXX_QUAL_RATE").toString()));
                    if(Double.valueOf(String.valueOf(avgWindPlantData.get(0).get("TJXX_NUM"))).intValue()>0){
                        windFileScoreEntity.setTJXXSendRate(100);
                    }else {
                        windFileScoreEntity.setTJXXSendRate(0);
                    }
                    //插入风电表中
                    plantDataMapper.insertWindFileScoreEntity(windFileScoreEntity);
                } else if (plantType.equals("pv")) {
                    // 光伏场站
                    PvFileScoreEntity pvFileScoreEntity = new PvFileScoreEntity();
                    pvFileScoreEntity.setPlantId(plantId);
                    pvFileScoreEntity.setPlantName(plantName);
                    pvFileScoreEntity.setPlantNameENG(plantNameENG);
                    pvFileScoreEntity.setDateTime(endTime);
                    pvFileScoreEntity.setAreaId(areaId);
                    pvFileScoreEntity.setStaticType(staticType);
                    // 查询该风电场站的平均分
                    List<Map<String, Object>> avgPvPlantData = plantDataMapper.selectAvgPvPlantData(plantId,startTime,endTime);
                    // 插入箱变方阵
                    pvFileScoreEntity.setXB_FZNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("XB_FZ_NUM"))).intValue());
                    pvFileScoreEntity.setXB_FZRate(Float.parseFloat(avgPvPlantData.get(0).get("XB_FZ_RATE").toString()));
                    pvFileScoreEntity.setXB_FZScore(Float.parseFloat(avgPvPlantData.get(0).get("XB_FZ_SCORE").toString()));
                    pvFileScoreEntity.setXB_FZFullScore(Float.parseFloat(avgPvPlantData.get(0).get("XB_FZ_FULL_SCORE").toString()));
                    pvFileScoreEntity.setXB_FZQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("XB_FZ_QUAL_RATE").toString()));
                    if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("XB_FZ_NUM"))).intValue()>0){
                        pvFileScoreEntity.setXB_FZSendRate(100);
                    }else {
                        pvFileScoreEntity.setXB_FZSendRate(0);
                    }
                    // 插入升压站信息
                    pvFileScoreEntity.setSYZXXNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("SYZXX_NUM"))).intValue());
                    pvFileScoreEntity.setSYZXXRate(Float.parseFloat(avgPvPlantData.get(0).get("SYZXX_RATE").toString()));
                    pvFileScoreEntity.setSYZXXScore(Float.parseFloat(avgPvPlantData.get(0).get("SYZXX_SCORE").toString()));
                    pvFileScoreEntity.setSYZXXFullScore(Float.parseFloat(avgPvPlantData.get(0).get("SYZXX_FULL_SCORE").toString()));
                    pvFileScoreEntity.setSYZXXQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("SYZXX_QUAL_RATE").toString()));
                    if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("SYZXX_NUM"))).intValue()>0){
                        pvFileScoreEntity.setSYZXXSendRate(100);
                    }else {
                        pvFileScoreEntity.setSYZXXSendRate(0);
                    }
                    // 插入总体信息-气象环境
                    pvFileScoreEntity.setZTXX_QXHJ_TYGZNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_NUM"))).intValue());
                    pvFileScoreEntity.setZTXX_QXHJ_TYGZRate(Float.parseFloat(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_RATE").toString()));
                    pvFileScoreEntity.setZTXX_QXHJ_TYGZScore(Float.parseFloat(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_SCORE").toString()));
                    pvFileScoreEntity.setZTXX_QXHJ_TYGZFullScore(Float.parseFloat(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_FULL_SCORE").toString()));
                    pvFileScoreEntity.setZTXX_QXHJ_TYGZQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_QUAL_RATE").toString()));
                    if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("ZTXX_QXHJ_TYGZ_NUM"))).intValue()>0){
                        pvFileScoreEntity.setZTXX_QXHJ_TYGZSendRate(100);
                    }else {
                        pvFileScoreEntity.setZTXX_QXHJ_TYGZSendRate(0);
                    }
                    // 插入短期预测
                    pvFileScoreEntity.setDQYCNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("DQYC_NUM"))).intValue());
                    pvFileScoreEntity.setDQYCRate(Float.parseFloat(avgPvPlantData.get(0).get("DQYC_RATE").toString()));
                    pvFileScoreEntity.setDQYCScore(Float.parseFloat(avgPvPlantData.get(0).get("DQYC_SCORE").toString()));
                    pvFileScoreEntity.setDQYCFullScore(Float.parseFloat(avgPvPlantData.get(0).get("DQYC_FULL_SCORE").toString()));
                    pvFileScoreEntity.setDQYCQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("DQYC_QUAL_RATE").toString()));
                    if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("DQYC_NUM"))).intValue()>0){
                        pvFileScoreEntity.setDQYCSendRate(100);
                    }else {
                        pvFileScoreEntity.setDQYCSendRate(0);
                    }
                    // 插入超短期预测
                    pvFileScoreEntity.setCDQYCNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("CDQYC_NUM"))).intValue());
                    pvFileScoreEntity.setCDQYCRate(Float.parseFloat(avgPvPlantData.get(0).get("CDQYC_RATE").toString()));
                    pvFileScoreEntity.setCDQYCScore(Float.parseFloat(avgPvPlantData.get(0).get("CDQYC_SCORE").toString()));
                    pvFileScoreEntity.setCDQYCFullScore(Float.parseFloat(avgPvPlantData.get(0).get("CDQYC_FULL_SCORE").toString()));
                    pvFileScoreEntity.setCDQYCQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("CDQYC_QUAL_RATE").toString()));
                    if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("CDQYC_NUM"))).intValue()>0){
                        pvFileScoreEntity.setCDQYCSendRate(100);
                    }else {
                        pvFileScoreEntity.setCDQYCSendRate(0);
                    }
                    // 插入统计信息
                    pvFileScoreEntity.setTJXXNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("TJXX_NUM"))).intValue());
                    pvFileScoreEntity.setTJXXRate(Float.parseFloat(avgPvPlantData.get(0).get("TJXX_RATE").toString()));
                    pvFileScoreEntity.setTJXXScore(Float.parseFloat(avgPvPlantData.get(0).get("TJXX_SCORE").toString()));
                    pvFileScoreEntity.setTJXXFullScore(Float.parseFloat(avgPvPlantData.get(0).get("TJXX_FULL_SCORE").toString()));
                    pvFileScoreEntity.setTJXXQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("TJXX_QUAL_RATE").toString()));
                    if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("TJXX_NUM"))).intValue()>0){
                        pvFileScoreEntity.setTJXXSendRate(100);
                    }else {
                        pvFileScoreEntity.setTJXXSendRate(0);
                    }
                    // 插入逆变器-汇流箱
                    pvFileScoreEntity.setNBQ_HLXNum(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("NBQ_HLX_NUM"))).intValue());
                    pvFileScoreEntity.setNBQ_HLXRate(Float.parseFloat(avgPvPlantData.get(0).get("NBQ_HLX_RATE").toString()));
                    pvFileScoreEntity.setNBQ_HLXScore(Float.parseFloat(avgPvPlantData.get(0).get("NBQ_HLX_SCORE").toString()));
                    pvFileScoreEntity.setNBQ_HLXFullScore(Float.parseFloat(avgPvPlantData.get(0).get("NBQ_HLX_FULL_SCORE").toString()));
                    pvFileScoreEntity.setNBQ_HLXQualifiedRate(Float.parseFloat(avgPvPlantData.get(0).get("NBQ_HLX_QUAL_RATE").toString()));
                    if(Double.valueOf(String.valueOf(avgPvPlantData.get(0).get("NBQ_HLX_NUM"))).intValue()>0){
                        pvFileScoreEntity.setNBQ_HLXSendRate(100);
                    }else {
                        pvFileScoreEntity.setNBQ_HLXSendRate(0);
                    }
                    //插入光伏表中
                    plantDataMapper.insertPvFileScoreEntity(pvFileScoreEntity);
                }
            }
        }
    }

    @Override
    public void getPlantDataScoreByYesterday(Date endTime) {
        // 查全网所有场站id
        List<Map<String, Object>> plantData = plantDataMapper.selectAllplantData();
        if (plantData != null) {
            //遍历该省下市级信息id,name,code
            for (Map<String, Object> plantMap : plantData) {
                // 获取场站Id
                String plantId = plantMap.get("ID").toString();
                // 获取区域Id
                String areaId = plantMap.get("AREAID").toString();
                // 获取场站名称
                String plantName = plantMap.get("NAME").toString();
                // 获取场站英文标识符
                String plantNameENG = null;

                if(plantMap.get("CODE")==null){
                    plantNameENG="null";
                }else {
                    plantNameENG=plantMap.get("CODE").toString();
                }

                String plantType = plantMap.get("PLANT_TYPE").toString();
                int staticType = 1;
                if (plantType.equals("wind")) {
                    // 风电场站
                    WindDataScoreEntity windDataScoreEntity = new WindDataScoreEntity();
                    windDataScoreEntity.setPlantId(plantId);
                    windDataScoreEntity.setPlantName(plantName);
                    windDataScoreEntity.setPlantNameENG(plantNameENG);
                    windDataScoreEntity.setDateTime(endTime);
                    windDataScoreEntity.setAreaId(areaId);
                    windDataScoreEntity.setStaticType(staticType);

                    windDataScoreEntity = windPlantDataScoreService.getFDJZDataScore(windDataScoreEntity);
                    windDataScoreEntity = windPlantDataScoreService.getSYZXXDataScore(windDataScoreEntity);
                    windDataScoreEntity = windPlantDataScoreService.getZTXXDataScore(windDataScoreEntity);
                    windDataScoreEntity = windPlantDataScoreService.getDQYCDataScore(windDataScoreEntity);
                    windDataScoreEntity = windPlantDataScoreService.getCDQYCDataScore(windDataScoreEntity);
                    windDataScoreEntity = windPlantDataScoreService.getTJXXDataScore(windDataScoreEntity);
                    //插入风电表中
                    //windDataScoreEntity.setDateTime(new Date());
                    plantDataMapper.insertWindDataScoreEntity(windDataScoreEntity);
                } else if (plantType.equals("pv")) {
                    // 光伏场站
                    PvDataScoreEntity pvDataScoreEntity = new PvDataScoreEntity();
                    pvDataScoreEntity.setPlantId(plantId);
                    pvDataScoreEntity.setPlantName(plantName);
                    pvDataScoreEntity.setPlantNameENG(plantNameENG);
                    pvDataScoreEntity.setDateTime(endTime);
                    pvDataScoreEntity.setAreaId(areaId);
                    pvDataScoreEntity.setStaticType(staticType);

                    pvDataScoreEntity = pvPlantDataScoreService.getXBFZDataScore(pvDataScoreEntity);
                    pvDataScoreEntity = pvPlantDataScoreService.getSYZXXDataScore(pvDataScoreEntity);
                    pvDataScoreEntity = pvPlantDataScoreService.getZTXXDataScore(pvDataScoreEntity);
                    pvDataScoreEntity = pvPlantDataScoreService.getDQYCDataScore(pvDataScoreEntity);
                    pvDataScoreEntity = pvPlantDataScoreService.getCDQYCDataScore(pvDataScoreEntity);
                    pvDataScoreEntity = pvPlantDataScoreService.getTJXXDataScore(pvDataScoreEntity);
                    pvDataScoreEntity = pvPlantDataScoreService.getNBQHLXDataScore(pvDataScoreEntity);
                    //插入光伏表中
                    //pvDataScoreEntity.setDateTime(new Date());
                    plantDataMapper.insertPvDataScoreEntity(pvDataScoreEntity);
                }
            }
        }
    }


}
